<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>

<div>
    <div>
        <div>盒子</div>
    </div>
</div>
<script> 
var div = document.getElementsByTagName("div");
// 获取3个嵌套的div元素
for(var i=0;i<div.length;i++){				// 遍历嵌套的div元素
    div[i].onmouseover = function(e){ 		// 注册移过事件处理函数
        this.style.border = "solid blue";
    }
    div[i].onmouseout = function(){			// 注册移出事件处理函数
        this.style.border = "solid red";
    }
}
</script>

</body>
</html>
